<#assign module="car"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/uploadify.css">
<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
</@override>
<@override name="body">

	<div class="row">
		<div class="col-md-12 col-lg-12">
		<div class="tabbable"> 
			<div class="tab-content">
			
			    <div class="tab-pane active" id="tab1">
		    		<div class="row margin-top">
						<div class="col-xs-12">
							<div class="table-responsive">
								<div class="panel panel-default">
									<div class="panel-heading">
										填写品牌信息
									</div>
									<div class="panel-body">
				    				<form class="form-horizontal"  action="${ctx}/brand/add" enctype="multipart/form-data" method="post">
							            <div class="form-group">   
							      		 	    <label class="col-sm-3 control-label"><em>*</em>品牌名称：</label>
							      		       	<div class="col-sm-3">
								                   	<input class="form-control"  name="name" type="text" placeholder="如:宝马" required  />
								                </div>
						      		    </div>
						  			    <div class="form-group">
						                    <label class="col-sm-3 control-label"><em>*</em>品牌型号名称：</label>
						                    <div class="col-sm-3">
						                    	<input  class="form-control" name="typeNames" type="text" placeholder="如:宝马X1" required />
						                    </div>
		              					 </div>
		              					 <div class="form-group">
						                 	<label class="col-sm-3 control-label">品牌型号名称：</label>
						                    <div class="col-sm-3">
						                    	<input  class="form-control" name="typeNames" type="text" placeholder="如:宝马3系"  />
						                    </div>
		              					 </div>
		              					 <div class="form-group">
						                 	<label class="col-sm-3 control-label">品牌型号名称：</label>
						                    <div class="col-sm-3">
						                    	<input  class="form-control" name="typeNames" type="text" placeholder="如:宝马4系"  />
						                    </div>
		              					 </div>
		              					 <div class="form-group">
						                 	<label class="col-sm-3 control-label">品牌型号名称：</label>
						                    <div class="col-sm-3">
						                    	<input  class="form-control" name="typeNames" type="text" placeholder="如:宝马X4"  />
						                    </div>
		              					 </div>
		              					 <div class="form-group">
						                 	<label class="col-sm-3 control-label">品牌型号顺序：</label>
						                    <div class="col-sm-3">
						                    	<input type="number" class="form-control" name="sequence" value="1">
						                    </div>
		              					 </div>
		              					 
		              					 <div class="form-group">
						                    <label class="col-sm-3 control-label"><em>*</em>品牌图片：</label>
						                  	<div class="col-sm-2">
												<div style="margin-top:10px">
													<img id="picture_img" style="width:200px;height:200px;"/>
												</div>
												<input style="display:none;" type="file" name="pic1" id="picture_file" accept=".bmp,.gif,.jpeg,.jpg,.png">
												<input id="picture_brand" type="hidden" name="photo" />
											</div>
											<div class="col-sm-1">
											<button type="button" class="pull-left button button-pill button-flat-primary button-tiny " id="picture_upload_brand"><i class="glyphicon glyphicon-open"></i>&nbsp;图片上传</button>
											</div>
											
						                </div>
		              					 
						                <div class="form-group">
						                	<div class="col-sm-4">
						                	</div>
						                	<div class="col-sm-3">
								                <input  type="submit" class="btn btn-primary" value="保存">
								                <input type="button" class="btn btn-default" onclick="window.location.href = '${ctx}/brand/list';" value="返回">
							            	</div>
							            </div>
						            </form>
						        	</div>
								</div>
							</div>
						</div>
					</div>
			    </div>
			   
			</div>
		</div>
		</div>
	</div>
	

</@override>
<@override name="footer">

<script src="${ctx}/assets/js/ajaxfileupload.js"></script>
<script src="${ctx}/assets/kindeditor/kindeditor-all-min.js"></script>
<script src="${ctx}/assets/kindeditor/lang/zh_CN.js"></script>
<script src="${ctx}/assets/js/bootstrap-datetimepicker.min.js"></script>
<script src="${ctx}/assets/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
	<#if message??>
		$.scojs_message("${message}", $.scojs_message.TYPE_ERROR);
	</#if>
	$(document).ready(function(){
		$("#picture_upload_brand").click(function(){
			$("#picture_file").click();
		});
		$("#picture_img").click(function(){
			$("#picture_file").click();
		});
		
		$(document).on('change','#picture_file',function(){
			if($.trim($(this).val())){
			 	$.ajaxFileUpload({
	                url:'${ctx}/common/uploadTemp',
	                secureuri:false,
	                fileElementId:'picture_file',
	                dataType: 'json',
	                data:{'type':'brand'},
	                success: function (result, textStatus) {
	                
	                	$('#picture_img').attr('src','${ctx}/upload/brand/'+result.url);
	                	var url='upload/brand/'+result.url;
	                	$('#picture_brand').val(url);
	                }
	            });
			}
		});
		
		$("#submit_form").submit(function(){
			$("#submit_button").attr("disabled",true);
			
			if($("#name").val()==""){
		    	$.scojs_message('请填写品牌名称', $.scojs_message.TYPE_ERROR);
		    	$("#submit_button").attr("disabled",false);
		    	return false;
		    }
			
		    if($("#picture").val()==""){
		    	$.scojs_message('请上传品牌图片', $.scojs_message.TYPE_ERROR);
		    	$("#submit_button").attr("disabled",false);
		    	return false;
		    }
		    
			return true;
		});
	
	});
</script>

</@override>
<@extends name="../layout.ftl"/>